home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / math / gle-3.000 / gle-3 / gle / surfcmd.c < prev    next >
C/C++ Source or Header  |  1995-02-07  |  2KB  |  74 lines

  1. /* This is the surface command which translates to run the individual
  2.    surface programs:
  3.       surface myfile -dps       ---> surf_ps myfile
  4. */
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <string.h>
  8. #include <sys/types.h>
  9. #include <sys/wait.h>
  10. #define false 0
  11. #define true (!false)
  12. #include "glepath.h"
  13. main(int argc,char *argv[])
  14. {
  15.     static char buff[200];
  16.     static char restofline[200];
  17.     static char surfacefile[200];
  18.     static char device[200];
  19.     static char outfile[200];
  20.     static char bindir[200];
  21.     char *s;
  22.     int i;
  23.  
  24. /*  Get the directory containing the gle_* binaries */
  25.     s = getenv("SURF_TOP");
  26.     if (s!=NULL) {
  27.         strcpy(bindir,s);
  28.     } else {
  29.         strcpy(bindir,GLEBINS);
  30.     }
  31.     if (strlen(bindir)>1) {
  32.         if (bindir[strlen(bindir)-1] != '/')
  33.             strcat(bindir,"/");
  34.     }
  35.  
  36.     if (argc<2) {
  37.       printf("Usage: surface filename.gle -ddevice\n");
  38.       printf("    surface test        (Dumb terminal) \n");
  39.       printf("    surface test -dx    (Xwindows) \n");
  40.       printf("    surface test -dtek  (TEK4010) \n");
  41.       printf("    surface test -dhpgl (HP Plotters) \n");
  42.       printf("    surface test -dps   (PostScript) \n");
  43.       printf("To find out what drivers are available type in:\n");
  44.       printf("         ls %ssurf_* \n", bindir);
  45.       printf(" \n");
  46.       return 0;
  47.     }
  48.     strcpy(device,"vt");
  49.     for (i=1;i<argc;i++) {
  50.         if (strncmp(argv[i],"-d",2)==0) strcpy(device,argv[i]+2);
  51.         else if (isalnum(*argv[i])) strcpy(surfacefile,argv[i]);
  52.         else {
  53.             strcat(restofline," ");
  54.             strcat(restofline,argv[i]);
  55.         }
  56.     }
  57.     strcpy(outfile,surfacefile);
  58.     s = strchr(outfile,'.');
  59.     if (s!=NULL) *s = 0;
  60.     strcat(outfile,".");
  61.     strcat(outfile,device);
  62.     sprintf(buff,"%ssurf_",bindir); /* , GLEBINSOD); */
  63.     strcat(buff,device);
  64.     strcat(buff," ");
  65.     strcat(buff,surfacefile);
  66.     strcat(buff," /output=");
  67.     strcat(buff,outfile);
  68.     strcat(buff,restofline);
  69.     printf("%s\n",buff);
  70.     execlp("sh","sh","-c", buff,0);
  71. }
  72.  
  73.  
  74.